package com.dao.impl;

import com.dao.GenChartDao;
import com.mapper.GenChartMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Repository
public class GenChartDaoImpl implements GenChartDao {
    @Resource
    GenChartMapper genChartMapper;
    public List<Map> getDataSet(String methodname) throws InvocationTargetException, IllegalAccessException {
        Method[] methods = genChartMapper.getClass().getDeclaredMethods();
        List<Map> listMap = new ArrayList<Map>();
        for(Method method:methods){
            //如果找到名字相同的方法.调用
            if(method.getName().equals(methodname)){
                listMap = (List<Map>)method.invoke(genChartMapper);//反射调用方法
            }
        }
        return listMap;
    }
}
